//
//  GuideViewController.m
//  AroundTheWorld
//
//  Created by IfelseGo on 16/5/29.
//  Copyright © 2016年 IfelseGo an. All rights reserved.
//

#import "GuideViewController.h"
#import "KSGuideManager.h"

#define kFirstLaunchKey     @"FirstLaunch"

@interface GuideViewController ()<KSGuideDelegate>

@end

@implementation GuideViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    NSMutableArray *paths = [NSMutableArray new];
    
    [paths addObject:[[NSBundle mainBundle] pathForResource:@"1" ofType:@"png"]];
    [paths addObject:[[NSBundle mainBundle] pathForResource:@"2" ofType:@"png"]];
    [paths addObject:[[NSBundle mainBundle] pathForResource:@"3" ofType:@"png"]];
    [paths addObject:[[NSBundle mainBundle] pathForResource:@"4" ofType:@"png"]];
    
    [[KSGuideManager shared] setDelegate:self];
    [[KSGuideManager shared] clearMark];
    [[KSGuideManager shared] showGuideViewWithImages:paths];
    
    [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:kFirstLaunchKey];
}

+ (BOOL)shouldShowGuide
{
    NSObject *value = [[NSUserDefaults standardUserDefaults] objectForKey:kFirstLaunchKey];
    if (value == nil) {
        return YES;
    }
    
    return NO;
}

#pragma mark - KSGuideDelegate

- (UIButton *)KSGuidLastPageButton {
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:CGRectMake(0, 0, 145, 40)];
    [button setTitle:@"体验新版" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor colorWithRed:44 / 255.0 green:180 / 255.0 blue:135 / 255.0 alpha:1.0] forState:UIControlStateNormal];
    [button.layer setCornerRadius:5];
    [button.layer setBorderColor:[UIColor whiteColor].CGColor];
    [button.layer setBorderWidth:1.0f];
    [button setBackgroundColor:[UIColor whiteColor]];
    [button setCenter:CGPointMake(kScreenBounds.size.width / 2, kScreenBounds.size.height - 80)];
    return button;
}
 
 - (void)KSGuidLastPageButtonDidOnClick {
     [self dismissViewControllerAnimated:NO completion:nil];
}
@end
